<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
    <input type="hidden" id="id" name="id" value="${orderbus.id!?c}" >
    <div class="layui-form-item">
        <label class="layui-form-label">全款订单单号</label>
        <div class="layui-input-block">
            <input readonly type="text" id="ordernum" name="ordernum" value="${orderbus.ordernum!}"  autocomplete="off" placeholder="请输入全款订单单号"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">定金单号</label>
        <div class="layui-input-block">
            <input readonly type="text" id="dingjinNum" name="dingjinNum" value="${orderbus.dingjinNum!}"  autocomplete="off" placeholder="请输入定金单号"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">尾款单号</label>
        <div class="layui-input-block">
            <input readonly type="text" id="weikuanNum" name="weikuanNum" value="${orderbus.weikuanNum!}"  autocomplete="off" placeholder="请输入尾款单号"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">下单时间</label>
        <div class="layui-input-block">
            <input readonly  type="text" id="ordertime" readonly  name="ordertime"   autocomplete="off" placeholder="请输入下单时间"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input readonly type="text" id="username" name="username" value="${orderbus.username!}"  autocomplete="off" placeholder="请输入姓名"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input readonly type="text" id="phone" name="phone" value="${orderbus.phone!}"  autocomplete="off" placeholder="请输入手机号"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选择时间</label>
        <div class="layui-input-block">
            <input readonly type="text" id="choosetime" name="choosetime" value="${orderbus.choosetime!}"  autocomplete="off" placeholder="请输入选择时间"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">上站地点</label>
        <div class="layui-input-block">
            <textarea readonly id="stationup"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">下站地点</label>
        <div class="layui-input-block">
            <textarea readonly id="stationdown"> </textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">人数</label>
        <div class="layui-input-block">
            <input type="text" id="peoplenumber" readonly name="peoplenumber" value="${orderbus.peoplenumber!}"  autocomplete="off" placeholder="请输入人数"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">订单状态 </label>
        <div class="layui-input-block">

            <select id="status" lay-filter="status"readonly>
                <option value="">请选择....</option>
                <option value="0">待确认</option>
                <option value="1">已确认待付款</option>
                <option value="2">进行中</option>
                <option value="3">已结束</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户id</label>
        <div class="layui-input-block">
            <input type="text" id="userid" readonly name="userid" value="${orderbus.userid!}"  autocomplete="off" placeholder="请输入用户id"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <input type="text" id="beizhu" readonly name="beizhu" value="${orderbus.beizhu!}"  autocomplete="off" placeholder="请输入备注"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">全款金额</label>
        <div class="layui-input-block">
            <input type="text" id="jine" readonly name="jine" value="${orderbus.jine!}"  autocomplete="off" placeholder="请输入全款金额"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">尾款金额</label>
        <div class="layui-input-block">
            <input type="text" id="weikuan"   name="weikuan" oninput="sumMoeny()" value="${orderbus.weikuan!}"  autocomplete="off" placeholder="请输入尾款金额"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">定金金额</label>
        <div class="layui-input-block">
            <input type="text" id="dingjin"   name="dingjin" oninput="sumMoeny()" value="${orderbus.dingjin!}"  autocomplete="off" placeholder="请输入定金金额"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">租车用途</label>
        <div class="layui-input-block">
            <input type="text" id="yongtu"readonly name="yongtu" value="${orderbus.yongtu!}"  autocomplete="off" placeholder="请输入租车用途"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">已支付金额</label>
        <div class="layui-input-block">
            <input type="text" id="payMoney"  readonlyname="payMoney" value="${orderbus.payMoney!}"  autocomplete="off" placeholder="请输入已支付金额"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">支付状态 </label>
        <div class="layui-input-block">

            <select id="payStatus" readonly lay-filter="payStatus">
                <option value="">请选择....</option>
                <option value="0">未支付</option>
                <option value="1">仅支付定金</option>
                <option value="2">支付完毕(全款)</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">定金支付时间</label>
        <div class="layui-input-block">
            <input type="text" id="paytime1"  readonlyname="paytime1" value="${orderbus.paytime1!}"  autocomplete="off" placeholder="请输入定金支付时间"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">全款支付时间</label>
        <div class="layui-input-block">
            <input type="text" id="paytime2" readonly name="paytime2" value="${orderbus.paytime2!}"  autocomplete="off" placeholder="请输入全款支付时间"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">尾款支付时间</label>
        <div class="layui-input-block">
            <input type="text" readonly id="paytime3" name="paytime3" value="${orderbus.paytime3!}"  autocomplete="off" placeholder="请输入尾款支付时间"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">支付类型 </label>
        <div class="layui-input-block">
            <select readonly  id="payType" lay-filter="payType">
                <option value="">请选择....</option>
                <option value="-1">没有支付</option>
                <option value="0">定金+尾款支付</option>
                <option value="1">全款直接支付</option>
            </select>
        </div>
    </div>

    <div align="center">
        <button type="button" class="layui-btn" id="adopt">通过</button>
        <button type="button" class="layui-btn" id="noAdopt">不通过</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script src="${base}/static/win10/js/zhang.js?t=1"></script>
<script>
function sumMoeny(){
  var weikuan=  $("#weikuan").val();
  var dingjin=  $("#dingjin").val();
  var   num =Number(weikuan)+Number(dingjin);
    $("#jine").val( num.toFixed(2));
}
    layui.use(['form', 'layer','laydate'], function() {
        var form = layui.form
            , layer = layui.layer;
        var laydate = layui.laydate;
        if("${orderbus.paytime3!}"!=null&&"${orderbus.paytime3!}"!=""){
            $("#paytime3").val(changeDateFormat("${orderbus.paytime3!}"))
        }

        if("${orderbus.paytime2!}"!=null&&"${orderbus.paytime2!}"!=""){
            $("#paytime2").val(changeDateFormat("${orderbus.paytime2!}"))
        }

        if("${orderbus.paytime1!}"!=null&&"${orderbus.paytime1!}"!=""){
            $("#paytime1").val(changeDateFormat("${orderbus.paytime1!}"))
        }
        if("${orderbus.ordertime!}"!=null&&"${orderbus.ordertime!}"!=""){
            $("#ordertime").val(changeDateFormat("${orderbus.ordertime!}"))
        }
        var payStatus="${orderbus.payStatus!}";
        $("#payStatus").val(payStatus)
        var status="${orderbus.status!}";
        $("#status").val(status)
        var payType="${orderbus.payType!}";
        $("#payType").val(payType)

        form.render();
        var stationupJson='${orderbus.stationup!}';
if(stationupJson!=null&&stationupJson!=""){
    stationupJson=JSON.parse(stationupJson);
 $("#stationup").val("地点："+stationupJson.address+" \n 经度："+stationupJson.latitude+" \n 纬度："+stationupJson.longitude)
}
        var stationdownJson='${orderbus.stationdown!}';
if(stationdownJson!=null&&stationdownJson!=""){
    stationdownJson=JSON.parse(stationdownJson);
 $("#stationdown").val("地点："+stationdownJson.address+" \n 经度："+stationdownJson.latitude+" \n 纬度："+stationdownJson.longitude)
}
        laydate.render({
            elem: '#paytime3' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,type: 'datetime'

        });
        laydate.render({
            elem: '#paytime2' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,type: 'datetime'
        });

        laydate.render({
            elem: '#paytime1' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,type: 'datetime'
        });

        laydate.render({
            elem: '#choosetime' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,type: 'datetime'
        });


        $("#adopt").on("click",function () {
            if($("#weikuan").val().length<1){
                layer.msg("请输入尾款金额");
                return false;
            }
            if($("#dingjin").val().length<1){
                layer.msg("请输入定金金额");
                return false;
            }
            var formDate = {
                id:$("#id").val(),
                jine:$("#jine").val(),
                weikuan:$("#weikuan").val(),
                dingjin:$("#dingjin").val(),
                status:1
            };
            $.ajax({
                type: "POST",
                url: base+"/bus/orderbus/editOrderbus",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href=base+"/bus/orderbus/main.html"
                    } else {

                    }
                }
            });
        })

        $("#noAdopt").on("click",function () {
            layer.confirm('是否确定不通过?',function(index){
                $.ajax({
                    type:"POST",
                    url:base+'/bus/orderbus/delOrderbus',
                    data:{"id":$("#id").val()},
                    success:function(data){
                        if(data.code===200){
                            layer.msg(data.message)
                            setTimeout(function () {
                                window.location.href=base+"/bus/orderbus/main.html"
                            }, 500)
                        }else{
                            layer.msg(data.message)
                        }
                    }
                });
            });
        })

        $("#submit").on("click",function () {
            /*    if(check()===false){
                    return;
                }*/

            var formDate = {
                id:$("#id").val(),
                ordernum:$("#ordernum").val(),
                dingjinNum:$("#dingjinNum").val(),
                weikuanNum:$("#weikuanNum").val(),
                username:$("#username").val(),
                phone:$("#phone").val(),
                choosetime:$("#choosetime").val(),
                peoplenumber:$("#peoplenumber").val(),
                status:$("#status").val(),
                userid:$("#userid").val(),
                beizhu:$("#beizhu").val(),
                jine:$("#jine").val(),
                weikuan:$("#weikuan").val(),
                dingjin:$("#dingjin").val(),
                yongtu:$("#yongtu").val(),
                payMoney:$("#payMoney").val(),
                payStatus:$("#payStatus").val(),
                paytime1:$("#paytime1").val(),
                paytime2:$("#paytime2").val(),
                paytime3:$("#paytime3").val(),
                payType:$("#payType").val()
            }
            $.ajax({
                type: "POST",
                url: base+"/bus/orderbus/editOrderbus",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href=base+"/bus/orderbus/main.html"
                    } else {

                    }
                }
            });
        })







        function check(){
            if($("#ordernum").val().length<1){
                layer.msg("请输入全款订单单号");
                return false;
            }
            if($("#dingjinNum").val().length<1){
                layer.msg("请输入定金单号");
                return false;
            }
            if($("#weikuanNum").val().length<1){
                layer.msg("请输入尾款单号");
                return false;
            }
            if($("#ordertime").val().length<1){
                layer.msg("请输入下单时间");
                return false;
            }
            if($("#username").val().length<1){
                layer.msg("请输入姓名");
                return false;
            }
            if($("#phone").val().length<1){
                layer.msg("请输入手机号");
                return false;
            }
            if($("#choosetime").val().length<1){
                layer.msg("请输入选择时间");
                return false;
            }
            if($("#stationup").val().length<1){
                layer.msg("请输入上站地点");
                return false;
            }
            if($("#stationdown").val().length<1){
                layer.msg("请输入下站地点");
                return false;
            }
            if($("#peoplenumber").val().length<1){
                layer.msg("请输入人数");
                return false;
            }
            if($("#status").val().length<1){
                layer.msg("请输入订单状态0-待确认 1-已确认待付款 2-进行中 3-已结束 ");
                return false;
            }
            if($("#userid").val().length<1){
                layer.msg("请输入用户id");
                return false;
            }
            if($("#beizhu").val().length<1){
                layer.msg("请输入备注");
                return false;
            }
            if($("#jine").val().length<1){
                layer.msg("请输入全款金额");
                return false;
            }
            if($("#weikuan").val().length<1){
                layer.msg("请输入尾款金额");
                return false;
            }
            if($("#dingjin").val().length<1){
                layer.msg("请输入定金金额");
                return false;
            }
            if($("#yongtu").val().length<1){
                layer.msg("请输入租车用途");
                return false;
            }
            if($("#payMoney").val().length<1){
                layer.msg("请输入已支付金额");
                return false;
            }
            if($("#payStatus").val().length<1){
                layer.msg("请输入支付状态0=未支付 1=仅支付定金 2=支付完毕(全款) ");
                return false;
            }
            if($("#paytime1").val().length<1){
                layer.msg("请输入定金支付时间");
                return false;
            }
            if($("#paytime2").val().length<1){
                layer.msg("请输入全款支付时间");
                return false;
            }
            if($("#paytime3").val().length<1){
                layer.msg("请输入尾款支付时间");
                return false;
            }
            if($("#payType").val().length<1){
                layer.msg("请输入支付类型 -1 没有支付 0定金+尾款支付 1全款直接支付");
                return false;
            }
        }
    });

</script>
</body>
</html>